import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementUI, { Switch } from "element-ui";
import VueRouter from "vue-router";
import "../src/utils/rem";
// import VueLazyload from "vue-lazyload";
// 引入富文本组件
import QuillEditor from "vue-quill-editor";
// 引入富文本组件样式
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import "element-ui/lib/theme-chalk/index.css";
// import VueLazy from "vue-lazyload";
const imgurl = "http://m.asmm.vip";
const imgupload = "http://management.api.asmm.vip";
import "./utils/rem";
import card from "../src/components/from/card.vue";
import buttonCn from "../src/components/from/button-cn.vue";
import alertCn from "../src/components/from/alert-cn.vue";
import axios from "axios";
import JsonExcel from "vue-json-excel";
Vue.component("downloadExcel", JsonExcel);
// import "./components/style/init_el_checkout.scss"
Vue.component("card", card);
// import './utils/rem.js'
Vue.component("button-cn", buttonCn);
Vue.component("alert-cn", alertCn);
Vue.prototype.$imgupload = imgupload;
Vue.prototype.$imgurl = imgurl;
Vue.prototype.$vuex = store;
// Vue.use(VueLazy);
Vue.use(ElementUI);
Vue.config.productionTip = false;
Vue.use(VueRouter);
Vue.use(QuillEditor);
// Vue.use(VueLazyload)

// with options
// Vue.use(VueLazyload, {
//   preLoad: 1.3,
//   error: 'dist/error.png',
//   loading: 'dist/loading.gif',
//   attempt: 1
// })
Vue.prototype.$axios = axios;

Vue.directive("focus", {
  inserted: function (el) {
    console.log(el);
    el.children[0].focus();
  },
});
router.beforeEach((to, from, next) => {
  if (to.path === "/login" || to.path === "/ForgotPassword") {
    return next();
  }

  const tokenStr = window.sessionStorage.getItem("id");
  if (!tokenStr) {
    return next("/login");
  } else {
    next();
  }
});

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
 